package avicit.bdp.dds.dao.entity;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

@ApiModel(value = "TaskNodes", description = "任务节点实体类")
@Table(name = "bdp_dds_task_nodes")
public class TaskNodes extends BaseDTO {
	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	@Id
	@LogField
	@ApiModelProperty(value = "id", name = "id")
	@FieldRemark(column = "id", field = "id", name = "id")
	@javax.persistence.Id
	@Column(name = "id")
	private String id;

	/**
	 * 节点名称
	 */
	@LogField
	@ApiModelProperty(value = "节点名称", name = "name")
	@FieldRemark(column = "name", field = "name", name = "节点名称")
	private String name;

	/**
	 * 节点名称
	 */
	@LogField
	@ApiModelProperty(value = "节点代码", name = "name")
	@FieldRemark(column = "code", field = "code", name = "节点代码")
	private String code;

	/**
	 * 图标
	 */
	@LogField
	@ApiModelProperty(value = "图标", name = "icon")
	@FieldRemark(column = "icon", field = "icon", name = "图标")
	private String icon;

	/**
	 * 类型 commonFlow/sparkFlow
	 */
	@LogField
	@ApiModelProperty(value = "类型", name = "type")
	@FieldRemark(column = "type", field = "type", name = "类型")
	private String type;

	/**
	 * 所属分类ID
	 */
	@LogField
	@ApiModelProperty(value = "父id", name = "pid")
	@FieldRemark(column = "pid", field = "pid", name = "父id")
	private String pid;

	/**
	 * 执行类名称
	 */
	@LogField
	@ApiModelProperty(value = "执行类名称", name = "execClassName")
	@FieldRemark(column = "exec_class_name", field = "execClassName", name = "执行类名称")
	private String execClassName;

	/**
	 * 编程类型  spark执行节点：(0-- java;1--  scala;2--  python); 5--python执行节点
	 */
	@LogField
	@ApiModelProperty(value = "输入输出参数", name = "programType")
	@FieldRemark(column = "program_type", field = "programType", name = "编程类型")
	private Integer programType;


	/**
	 * 节点包路径
	 */
	@LogField
	@ApiModelProperty(value = "节点包路径", name = "nodeFilePath")
	@FieldRemark(column = "node_file_path", field = "nodeFilePath", name = "节点包路径")
	private String nodeFilePath;

	/**
	 * python内容
	 */
	@LogField
	@ApiModelProperty(value = "python内容", name = "content")
	@FieldRemark(column = "content", field = "content", name = "python内容")
	private String content;

	/**
	 * 颜色
	 */
	@LogField
	@ApiModelProperty(value = "颜色", name = "color")
	@FieldRemark(column = "color", field = "color", name = "颜色")
	private String color;

	/**
	 * 备注
	 */
	@LogField
	@ApiModelProperty(value = "备注", name = "remark")
	@FieldRemark(column = "remark", field = "remark", name = "备注")
	private String remark;

	/**
	 * 排序
	 */
	@LogField
	@ApiModelProperty(value = "排序", name = "orderBy")
	@FieldRemark(column = "order_by", field = "orderBy", name = "排序")
	@Column(name = "order_by")
	private Integer orderBy;

	/**
	 * 是否显示.0：不显示；1：显示
	 */
	@LogField
	@ApiModelProperty(value = "是否显示", name = "showed")
	@FieldRemark(column = "showed", field = "showed", name = "是否显示")
	@Column(name = "showed")
	private Integer showed;

	/**
	 * 输入输出参数，JSON串
	 */
	@LogField
	@ApiModelProperty(value = "输入输出参数", name = "params")
	@FieldRemark(column = "params", field = "params", name = "输入输出参数")
	private String params;

	/**
	 * 算法分类；0:内置算法、1:自定义算法、2:其他
	 */
	@LogField
	@ApiModelProperty(value = "算法分类", name = "algoType")
	@FieldRemark(column = "algo_type", field = "algoType", name = "算法分类")
	private Integer algoType;

	/**
	 * 节点分类；0：算法节点；1：算法分类节点
	 */
	@LogField
	@ApiModelProperty(value = "节点分类", name = "treeNodeFlag")
	@FieldRemark(column = "tree_node_flag", field = "treeNodeFlag", name = "节点分类")
	private Integer treeNodeFlag;

	/**
	 * 子节点
	 */
	@Transient
	private List<TaskNodes> children;

	/**
	 * 编程类型名称
	 */
	@Transient
	private String programTypeName;

	/**
	 * 所属关系
	 */
	@Transient
	private String relation;

	/**
	 * 所属分类名称
	 */
	@Transient
	private String typeName;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(Integer orderBy) {
		this.orderBy = orderBy;
	}

	public String getParams() {
		return params;
	}

	public void setParams(String params) {
		this.params = params;
	}

	public String getNodeFilePath() {
		return nodeFilePath;
	}

	public void setNodeFilePath(String nodeFilePath) {
		this.nodeFilePath = nodeFilePath;
	}

	public Integer getShowed() {
		return showed;
	}

	public void setShowed(Integer showed) {
		this.showed = showed;
	}

	public String getExecClassName() {
		return execClassName;
	}

	public void setExecClassName(String execClassName) {
		this.execClassName = execClassName;
	}

	public Integer getProgramType() {
		return programType;
	}

	public void setProgramType(Integer programType) {
		this.programType = programType;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getAlgoType() {
		return algoType;
	}

	public void setAlgoType(Integer algoType) {
		this.algoType = algoType;
	}

	public Integer getTreeNodeFlag() {
		return treeNodeFlag;
	}

	public void setTreeNodeFlag(Integer treeNodeFlag) {
		this.treeNodeFlag = treeNodeFlag;
	}

	public List<TaskNodes> getChildren() {
		return children;
	}

	public void setChildren(List<TaskNodes> children) {
		this.children = children;
	}

	public String getProgramTypeName() {
		return programTypeName;
	}

	public void setProgramTypeName(String programTypeName) {
		this.programTypeName = programTypeName;
	}

	public String getRelation() {
		return relation;
	}

	public void setRelation(String relation) {
		this.relation = relation;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	@Override
	public String getLogFormName() {
		if (StringUtils.isEmpty(super.logFormName)) {
			return "通用算法库模块";
		} else {
			return super.logFormName;
		}
	}

	@Override
	public String getLogTitle() {
		if (StringUtils.isEmpty(super.logTitle)) {
			return "通用算法库";
		} else {
			return super.logTitle;
		}
	}

	public static TaskNodes.Builder builder() {
		return new TaskNodes.Builder();
	}

	/**
	 * build构造器
	 */
	public static final class Builder {
		private String id;
		private String name;
		private String code;
		private String icon;
		private String type;
		private String pid;
		private String execClassName;
		private Integer programType;
		private String nodeFilePath;
		private String content;
		private String color;
		private String remark;
		private Integer orderBy;
		private Integer showed;
		private String params;
		private Integer algoType;
		private Integer treeNodeFlag;
		private List<TaskNodes> children;
		private String programTypeName;
		private String relation;
		private String typeName;

		private Builder() {
		}

		public static Builder aTaskNodes() {
			return new Builder();
		}

		public Builder id(String id) {
			this.id = id;
			return this;
		}

		public Builder name(String name) {
			this.name = name;
			return this;
		}

		public Builder code(String code) {
			this.code = code;
			return this;
		}

		public Builder icon(String icon) {
			this.icon = icon;
			return this;
		}

		public Builder type(String type) {
			this.type = type;
			return this;
		}

		public Builder pid(String pid) {
			this.pid = pid;
			return this;
		}

		public Builder execClassName(String execClassName) {
			this.execClassName = execClassName;
			return this;
		}

		public Builder programType(Integer programType) {
			this.programType = programType;
			return this;
		}

		public Builder nodeFilePath(String nodeFilePath) {
			this.nodeFilePath = nodeFilePath;
			return this;
		}

		public Builder content(String content) {
			this.content = content;
			return this;
		}

		public Builder color(String color) {
			this.color = color;
			return this;
		}

		public Builder remark(String remark) {
			this.remark = remark;
			return this;
		}

		public Builder orderBy(Integer orderBy) {
			this.orderBy = orderBy;
			return this;
		}

		public Builder showed(Integer showed) {
			this.showed = showed;
			return this;
		}

		public Builder params(String params) {
			this.params = params;
			return this;
		}

		public Builder algoType(Integer algoType) {
			this.algoType = algoType;
			return this;
		}

		public Builder treeNodeFlag(Integer treeNodeFlag) {
			this.treeNodeFlag = treeNodeFlag;
			return this;
		}

		public Builder children(List<TaskNodes> children) {
			this.children = children;
			return this;
		}

		public Builder programTypeName(String programTypeName) {
			this.programTypeName = programTypeName;
			return this;
		}

		public Builder relation(String relation) {
			this.relation = relation;
			return this;
		}

		public Builder typeName(String typeName) {
			this.typeName = typeName;
			return this;
		}

		public TaskNodes build() {
			TaskNodes taskNodes = new TaskNodes();
			taskNodes.setId(id);
			taskNodes.setName(name);
			taskNodes.setCode(code);
			taskNodes.setIcon(icon);
			taskNodes.setType(type);
			taskNodes.setPid(pid);
			taskNodes.setExecClassName(execClassName);
			taskNodes.setProgramType(programType);
			taskNodes.setNodeFilePath(nodeFilePath);
			taskNodes.setContent(content);
			taskNodes.setColor(color);
			taskNodes.setRemark(remark);
			taskNodes.setOrderBy(orderBy);
			taskNodes.setShowed(showed);
			taskNodes.setParams(params);
			taskNodes.setAlgoType(algoType);
			taskNodes.setTreeNodeFlag(treeNodeFlag);
			taskNodes.setChildren(children);
			taskNodes.setProgramTypeName(programTypeName);
			taskNodes.setRelation(relation);
			taskNodes.setTypeName(typeName);
			return taskNodes;
		}
	}
}
